﻿using Modbus.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace CameraSystem
{
    public class ModbusRTU
    {
        public IModbusMaster master;
     

        public ModbusRTU()
        {
        }


        public ushort[] ReadHoldingRegister(byte slave, ushort startAdd, ushort num)
        {
            //try
            //{

            return master.ReadHoldingRegisters(slave, startAdd, num);



        }



        public bool[] ReadCoil(byte slave, ushort startAdd, ushort num)
        {
            //try
            //{

            return master.ReadCoils(slave, startAdd, num);


        }






        public void WriteSingleRegister(byte slave, ushort startAdd, ushort num)
        {
            //try
            //{

            master.WriteSingleRegister(slave, startAdd, num);


        }


        public void WriteSingleCoil(byte slave, ushort startAdd, bool num)
        {
            try
            {
                master.WriteSingleCoil(slave, startAdd, num);
            }
            catch
            { }




        }

    }
}
